package com.iflytek.cosmo.ocr.common.util;

import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.core.Size;
import org.opencv.imgcodecs.Imgcodecs;
import org.opencv.imgproc.Imgproc;

public class PicUtils {
	static {
		/* System.loadLibrary(Core.NATIVE_LIBRARY_NAME); */
	}
	public static void main(String[] args) throws Exception {
		System.out.println(System.getProperty("java.library.path"));
		/*
		 * zoomImage("D:\\需求\\view\\不同大小图片\\不同大小图片\\18M.jpg",
		 * "D:\\需求\\view\\不同大小图片\\不同大小图片\\18M压缩后.jpg", 500,500, 0.8d);
		 */
		/*
		 * thumbnail("D:/需求/view/不同大小图片/不同大小图片/18M.jpg",
		 * "D:\\需求\\view\\不同大小图片\\不同大小图片\\18M压缩后.jpg", 0.8);
		 */

		try {
			System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

			Mat src = Imgcodecs.imread(
					"C:\\Users\\Administrator.DGYU.000\\Desktop\\18M.jpg");
			// 读取图像到矩阵中
			if (src.empty()) {
				throw new Exception("no file");
			}

			Mat dst = src.clone();
			// 复制矩阵进入dst

			float scale = 0.5f;
			float width = src.width();
			float height = src.height();

			Imgproc.resize(src, dst, new Size(width * scale, height * scale));
			Imgcodecs.imwrite(
					"C:\\Users\\Administrator.DGYU.000\\Desktop\\resize0.5.jpg",
					dst);

			scale = 1.5f;
			Imgproc.resize(src, dst, new Size(width * scale, height * scale));
			Imgcodecs.imwrite(
					"C:\\Users\\Administrator.DGYU.000\\Desktop\\resize1.5.jpg",
					dst);

			Imgproc.resize(src, dst, new Size(400, 400));
			Imgcodecs.imwrite(
					"C:\\Users\\Administrator.DGYU.000\\Desktop\\resize400.jpg",
					dst);
		} catch (Exception e) {
			System.out.println("例外：" + e);
		}
	}

}
